package emf2gwtbridge.generators;

import emf2gwtbridge.*;
import org.eclipse.emf.codegen.ecore.genmodel.*;

public class Request
{
  protected static String nl;
  public static synchronized Request create(String lineSeparator)
  {
    nl = lineSeparator;
    Request result = new Request();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "package ";
  protected final String TEXT_2 = ";";
  protected final String TEXT_3 = NL + NL + "@";
  protected final String TEXT_4 = "(value = ";
  protected final String TEXT_5 = ".class, locator=";
  protected final String TEXT_6 = ".class)" + NL + "public interface ";
  protected final String TEXT_7 = " extends ";
  protected final String TEXT_8 = NL + "{\t" + NL + "/*";
  protected final String TEXT_9 = NL + "    Operation ";
  protected final String TEXT_10 = NL + "translacja operacji" + NL + "uslugi zatem to operacje + standard(dao)      " + NL + "      */" + NL + "//   ";
  protected final String TEXT_11 = "<";
  protected final String TEXT_12 = "> find";
  protected final String TEXT_13 = "(Long id);" + NL + "}";
  protected final String TEXT_14 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    GenClass genClass = (GenClass)argument; GenPackage genPackage = genClass.getGenPackage(); GenModel genModel = genPackage.getGenModel();
    stringBuffer.append(TEXT_1);
    stringBuffer.append(GeneratorUtils.getRequestPackage(genPackage));
    stringBuffer.append(TEXT_2);
    genModel.markImportLocation(stringBuffer, genPackage);
    stringBuffer.append(TEXT_3);
    stringBuffer.append(genModel.getImportedName("com.google.web.bindery.requestfactory.shared.Service"));
    stringBuffer.append(TEXT_4);
    stringBuffer.append(genModel.getImportedName(GeneratorUtils.getServicePackage(genPackage) + "." + GeneratorUtils.getServiceClassName(genClass)));
    stringBuffer.append(TEXT_5);
    stringBuffer.append(genModel.getImportedName(GeneratorUtils.getServiceLocatorPackageName(genPackage) + "." + GeneratorUtils.getServiceLocatorClassName(genPackage)));
    stringBuffer.append(TEXT_6);
    stringBuffer.append(GeneratorUtils.getRequestClassName(genClass));
    stringBuffer.append(TEXT_7);
    stringBuffer.append(genModel.getImportedName("com.google.web.bindery.requestfactory.shared.RequestContext"));
    stringBuffer.append(TEXT_8);
    for (GenOperation genOperation : genClass.getGenOperations()) {
    stringBuffer.append(TEXT_9);
    stringBuffer.append(genOperation.getName());
    }
    stringBuffer.append(TEXT_10);
    stringBuffer.append(genModel.getImportedName("com.google.web.bindery.requestfactory.shared.Request"));
    stringBuffer.append(TEXT_11);
    stringBuffer.append(genModel.getImportedName(GeneratorUtils.getProxyPackage(genPackage) + "." + GeneratorUtils.getProxyClassName(genClass)));
    stringBuffer.append(TEXT_12);
    stringBuffer.append(genClass.getClassName());
    stringBuffer.append(TEXT_13);
    genModel.emitSortedImports();
    stringBuffer.append(TEXT_14);
    return stringBuffer.toString();
  }
}
